import React, { Fragment } from 'react'
import Header from './components/Header'
import { renderRoutes } from 'react-router-config'
import { actions } from './components/Header/store'
import { connect } from 'react-redux'

class App extends React.Component {
  render() {
    const { route, staticContext } = this.props
    return (
      <Fragment>
        <Header staticContext={staticContext}/>
        {renderRoutes(route.routes)}
      </Fragment>
    )
  }
}

App.loadData = store => {
  return store.dispatch(actions.getLogin())
}

const mapDispatchToProps = dispatch => ({
  getLogin() {
    dispatch(actions.getLogin())
  }
})

export default connect(
  null,
  mapDispatchToProps
)(App)
